<?php
	//var_dump($_POST);
	//将上传的的值 取出
	$userName = $_POST['userName'];
	$password = md5($_POST['password']);
	$auth = $_POST['level'];
	$uid = $_POST['uid'];
	//echo $uid;
	
	//判断账号 密码s 是否为空
	if(empty($_POST['userName']) || empty($_POST['password']) || empty($_POST['rePassword'])){
		header('location:./update.php?uid='.$uid);
		exit;
	}
	
	
	//判断密码是否一样
	if($_POST['password'] != $_POST['rePassword']){
		header('location:./update.php?uid='.$uid);
		exit;
	}
	
	
	
	//1 连接数据库
    $con = mysqli_connect('localhost','root','www');
	//2 连接字符集
	mysqli_set_charset($con,'utf8');
	//3 选择数据库
	mysqli_select_db($con,'admin');
	//4 准备SQL语句
	$SQL = "update user set userName='{$userName}',password='{$password}',auth={$auth} where id={$uid}";
	//5 执行SQL语句
	mysqli_query($con,$SQL);
	
	if(mysqli_affected_rows($con) >= 1){
		//echo 'cg';
		header('location:./userList.php');
	}else{
		header('location:./update.php?uid='.$uid);
	}
		
	mysqli_close($con);
	

?>